<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>psychsim.action</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="psychsim.world.World-class.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://pynadath.net:81/projects/psychsim">PsychSim</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="psychsim-module.html">Package&nbsp;psychsim</a> ::
        Module&nbsp;action
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="psychsim.action-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="psychsim.action-module.html">Module psychsim.action</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">xml</tt><tt class="py-op">.</tt><tt class="py-name">dom</tt><tt class="py-op">.</tt><tt class="py-name">minidom</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Document</tt><tt class="py-op">,</tt><tt class="py-name">Node</tt><tt class="py-op">,</tt><tt class="py-name">NodeList</tt><tt class="py-op">,</tt><tt class="py-name">parseString</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"> </tt>
<a name="Action"></a><div id="Action-def"><a name="L3"></a><tt class="py-lineno">  3</tt> <a class="py-toggle" href="#" id="Action-toggle" onclick="return toggle('Action');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="psychsim.action.Action-class.html">Action</a><tt class="py-op">(</tt><tt class="py-base-class">dict</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="Action-expanded"><a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring">    @cvar special: a list of keys that are reserved for system use</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-docstring">    @type special: str[]</tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line">    <tt id="link-0" class="py-name" targets="Variable psychsim.action.Action.special=psychsim.action.Action-class.html#special"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-0', 'special', 'link-0');">special</a></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-string">'subject'</tt><tt class="py-op">,</tt><tt class="py-string">'verb'</tt><tt class="py-op">,</tt><tt class="py-string">'object'</tt><tt class="py-op">]</tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"> </tt>
<a name="Action.__init__"></a><div id="Action.__init__-def"><a name="L10"></a><tt class="py-lineno"> 10</tt> <a class="py-toggle" href="#" id="Action.__init__-toggle" onclick="return toggle('Action.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">arg</tt><tt class="py-op">=</tt><tt class="py-op">{</tt><tt class="py-op">}</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.__init__-expanded"><a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">arg</tt><tt class="py-op">,</tt><tt class="py-name">Node</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line">            <tt class="py-name">dict</tt><tt class="py-op">.</tt><tt id="link-1" class="py-name" targets="Method psychsim.action.Action.__init__()=psychsim.action.Action-class.html#__init__,Method psychsim.agent.Agent.__init__()=psychsim.agent.Agent-class.html#__init__,Method psychsim.agent.ValueFunction.__init__()=psychsim.agent.ValueFunction-class.html#__init__,Method psychsim.probability.Distribution.__init__()=psychsim.probability.Distribution-class.html#__init__,Method psychsim.pwl.KeyedMatrix.__init__()=psychsim.pwl.KeyedMatrix-class.html#__init__,Method psychsim.pwl.KeyedPlane.__init__()=psychsim.pwl.KeyedPlane-class.html#__init__,Method psychsim.pwl.KeyedTree.__init__()=psychsim.pwl.KeyedTree-class.html#__init__,Method psychsim.pwl.KeyedVector.__init__()=psychsim.pwl.KeyedVector-class.html#__init__,Method psychsim.world.World.__init__()=psychsim.world.World-class.html#__init__"><a title="psychsim.action.Action.__init__
psychsim.agent.Agent.__init__
psychsim.agent.ValueFunction.__init__
psychsim.probability.Distribution.__init__
psychsim.pwl.KeyedMatrix.__init__
psychsim.pwl.KeyedPlane.__init__
psychsim.pwl.KeyedTree.__init__
psychsim.pwl.KeyedVector.__init__
psychsim.world.World.__init__" class="py-name" href="#" onclick="return doclink('link-1', '__init__', 'link-1');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Method psychsim.action.Action.parse()=psychsim.action.Action-class.html#parse,Method psychsim.agent.Agent.parse()=psychsim.agent.Agent-class.html#parse,Method psychsim.agent.ValueFunction.parse()=psychsim.agent.ValueFunction-class.html#parse,Method psychsim.probability.Distribution.parse()=psychsim.probability.Distribution-class.html#parse,Method psychsim.pwl.KeyedMatrix.parse()=psychsim.pwl.KeyedMatrix-class.html#parse,Method psychsim.pwl.KeyedPlane.parse()=psychsim.pwl.KeyedPlane-class.html#parse,Method psychsim.pwl.KeyedTree.parse()=psychsim.pwl.KeyedTree-class.html#parse,Method psychsim.pwl.KeyedVector.parse()=psychsim.pwl.KeyedVector-class.html#parse,Method psychsim.world.World.parse()=psychsim.world.World-class.html#parse"><a title="psychsim.action.Action.parse
psychsim.agent.Agent.parse
psychsim.agent.ValueFunction.parse
psychsim.probability.Distribution.parse
psychsim.pwl.KeyedMatrix.parse
psychsim.pwl.KeyedPlane.parse
psychsim.pwl.KeyedTree.parse
psychsim.pwl.KeyedVector.parse
psychsim.world.World.parse" class="py-name" href="#" onclick="return doclink('link-2', 'parse', 'link-2');">parse</a></tt><tt class="py-op">(</tt><tt class="py-name">arg</tt><tt class="py-op">)</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line">            <tt class="py-name">dict</tt><tt class="py-op">.</tt><tt id="link-3" class="py-name"><a title="psychsim.action.Action.__init__
psychsim.agent.Agent.__init__
psychsim.agent.ValueFunction.__init__
psychsim.probability.Distribution.__init__
psychsim.pwl.KeyedMatrix.__init__
psychsim.pwl.KeyedPlane.__init__
psychsim.pwl.KeyedTree.__init__
psychsim.pwl.KeyedVector.__init__
psychsim.world.World.__init__" class="py-name" href="#" onclick="return doclink('link-3', '__init__', 'link-1');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt><tt class="py-name">arg</tt><tt class="py-op">)</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_string</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
</div><a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line">         </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"> </tt>
<a name="Action.getParameters"></a><div id="Action.getParameters-def"><a name="L19"></a><tt class="py-lineno"> 19</tt> <a class="py-toggle" href="#" id="Action.getParameters-toggle" onclick="return toggle('Action.getParameters');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#getParameters">getParameters</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.getParameters-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.getParameters-expanded"><a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-docstring">        @return: list of special parameters for this action</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-docstring">        @rtype: str[]</tt> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-4" class="py-name" targets="Method psychsim.pwl.KeyedVector.filter()=psychsim.pwl.KeyedVector-class.html#filter"><a title="psychsim.pwl.KeyedVector.filter" class="py-name" href="#" onclick="return doclink('link-4', 'filter', 'link-4');">filter</a></tt><tt class="py-op">(</tt><tt class="py-keyword">lambda</tt> <tt class="py-name">k</tt><tt class="py-op">:</tt> <tt class="py-keyword">not</tt> <tt class="py-name">k</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-5" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-5', 'special', 'link-0');">special</a></tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">keys</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"> </tt>
<a name="Action.__setitem__"></a><div id="Action.__setitem__-def"><a name="L26"></a><tt class="py-lineno"> 26</tt> <a class="py-toggle" href="#" id="Action.__setitem__-toggle" onclick="return toggle('Action.__setitem__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#__setitem__">__setitem__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">key</tt><tt class="py-op">,</tt><tt class="py-param">value</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.__setitem__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.__setitem__-expanded"><a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_string</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line">        <tt class="py-name">dict</tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Method psychsim.action.Action.__setitem__()=psychsim.action.Action-class.html#__setitem__,Method psychsim.probability.Distribution.__setitem__()=psychsim.probability.Distribution-class.html#__setitem__,Method psychsim.pwl.KeyedMatrix.__setitem__()=psychsim.pwl.KeyedMatrix-class.html#__setitem__,Method psychsim.pwl.KeyedVector.__setitem__()=psychsim.pwl.KeyedVector-class.html#__setitem__"><a title="psychsim.action.Action.__setitem__
psychsim.probability.Distribution.__setitem__
psychsim.pwl.KeyedMatrix.__setitem__
psychsim.pwl.KeyedVector.__setitem__" class="py-name" href="#" onclick="return doclink('link-6', '__setitem__', 'link-6');">__setitem__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt><tt class="py-name">key</tt><tt class="py-op">,</tt><tt id="link-7" class="py-name" targets="Method psychsim.agent.Agent.value()=psychsim.agent.Agent-class.html#value"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-7', 'value', 'link-7');">value</a></tt><tt class="py-op">)</tt> </tt>
</div><a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"> </tt>
<a name="Action.clear"></a><div id="Action.clear-def"><a name="L30"></a><tt class="py-lineno"> 30</tt> <a class="py-toggle" href="#" id="Action.clear-toggle" onclick="return toggle('Action.clear');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#clear">clear</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.clear-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.clear-expanded"><a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_string</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line">        <tt class="py-name">dict</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name" targets="Method psychsim.action.Action.clear()=psychsim.action.Action-class.html#clear,Method psychsim.probability.Distribution.clear()=psychsim.probability.Distribution-class.html#clear"><a title="psychsim.action.Action.clear
psychsim.probability.Distribution.clear" class="py-name" href="#" onclick="return doclink('link-8', 'clear', 'link-8');">clear</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
</div><a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"> </tt>
<a name="Action.root"></a><div id="Action.root-def"><a name="L34"></a><tt class="py-lineno"> 34</tt> <a class="py-toggle" href="#" id="Action.root-toggle" onclick="return toggle('Action.root');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#root">root</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.root-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.root-expanded"><a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt class="py-docstring">        @return: the base action table, with only special keys "subject", "verb", and "object"</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"><tt class="py-docstring">        @rtype: L{Action}</tt> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line">        <tt id="link-9" class="py-name" targets="Method psychsim.action.Action.root()=psychsim.action.Action-class.html#root"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-9', 'root', 'link-9');">root</a></tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-op">}</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">key</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-10" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-10', 'special', 'link-0');">special</a></tt><tt class="py-op">:</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">has_key</tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line">                <tt id="link-11" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-11', 'root', 'link-9');">root</a></tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-12" class="py-name" targets="Class psychsim.action.Action=psychsim.action.Action-class.html"><a title="psychsim.action.Action" class="py-name" href="#" onclick="return doclink('link-12', 'Action', 'link-12');">Action</a></tt><tt class="py-op">(</tt><tt id="link-13" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-13', 'root', 'link-9');">root</a></tt><tt class="py-op">)</tt> </tt>
</div><a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"> </tt>
<a name="Action.__str__"></a><div id="Action.__str__-def"><a name="L45"></a><tt class="py-lineno"> 45</tt> <a class="py-toggle" href="#" id="Action.__str__-toggle" onclick="return toggle('Action.__str__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#__str__">__str__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.__str__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.__str__-expanded"><a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_string</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">            <tt class="py-name">elements</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">            <tt class="py-name">keys</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">keys</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">            <tt class="py-keyword">for</tt> <tt id="link-14" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-14', 'special', 'link-0');">special</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-15', 'special', 'link-0');">special</a></tt><tt class="py-op">:</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">has_key</tt><tt class="py-op">(</tt><tt id="link-16" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-16', 'special', 'link-0');">special</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">                    <tt class="py-name">elements</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">[</tt><tt id="link-17" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-17', 'special', 'link-0');">special</a></tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">                    <tt class="py-name">keys</tt><tt class="py-op">.</tt><tt class="py-name">remove</tt><tt class="py-op">(</tt><tt id="link-18" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-18', 'special', 'link-0');">special</a></tt><tt class="py-op">)</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">            <tt class="py-name">keys</tt><tt class="py-op">.</tt><tt class="py-name">sort</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">            <tt class="py-name">elements</tt> <tt class="py-op">+=</tt> <tt class="py-name">map</tt><tt class="py-op">(</tt><tt class="py-keyword">lambda</tt> <tt class="py-name">k</tt><tt class="py-op">:</tt> <tt class="py-name">self</tt><tt class="py-op">[</tt><tt class="py-name">k</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-name">keys</tt><tt class="py-op">)</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_string</tt> <tt class="py-op">=</tt> <tt class="py-string">'-'</tt><tt class="py-op">.</tt><tt id="link-19" class="py-name" targets="Method psychsim.pwl.VectorDistribution.join()=psychsim.pwl.VectorDistribution-class.html#join"><a title="psychsim.pwl.VectorDistribution.join" class="py-name" href="#" onclick="return doclink('link-19', 'join', 'link-19');">join</a></tt><tt class="py-op">(</tt><tt class="py-name">map</tt><tt class="py-op">(</tt><tt class="py-name">str</tt><tt class="py-op">,</tt><tt class="py-name">elements</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_string</tt> </tt>
</div><a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line"> </tt>
<a name="Action.__hash__"></a><div id="Action.__hash__-def"><a name="L58"></a><tt class="py-lineno"> 58</tt> <a class="py-toggle" href="#" id="Action.__hash__-toggle" onclick="return toggle('Action.__hash__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#__hash__">__hash__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.__hash__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.__hash__-expanded"><a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hash</tt><tt class="py-op">(</tt><tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line"> </tt>
<a name="Action.__xml__"></a><div id="Action.__xml__-def"><a name="L61"></a><tt class="py-lineno"> 61</tt> <a class="py-toggle" href="#" id="Action.__xml__-toggle" onclick="return toggle('Action.__xml__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#__xml__">__xml__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.__xml__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.__xml__-expanded"><a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">        <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt class="py-name">Document</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">        <tt id="link-20" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-20', 'root', 'link-9');">root</a></tt> <tt class="py-op">=</tt> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">createElement</tt><tt class="py-op">(</tt><tt class="py-string">'action'</tt><tt class="py-op">)</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">        <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">appendChild</tt><tt class="py-op">(</tt><tt id="link-21" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-21', 'root', 'link-9');">root</a></tt><tt class="py-op">)</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">key</tt><tt class="py-op">,</tt><tt id="link-22" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-22', 'value', 'link-7');">value</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">            <tt class="py-name">node</tt> <tt class="py-op">=</tt> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">createElement</tt><tt class="py-op">(</tt><tt class="py-string">'entry'</tt><tt class="py-op">)</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line">            <tt class="py-name">node</tt><tt class="py-op">.</tt><tt class="py-name">setAttribute</tt><tt class="py-op">(</tt><tt class="py-string">'key'</tt><tt class="py-op">,</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line">            <tt class="py-name">node</tt><tt class="py-op">.</tt><tt class="py-name">appendChild</tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">createTextNode</tt><tt class="py-op">(</tt><tt class="py-name">str</tt><tt class="py-op">(</tt><tt id="link-23" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-23', 'value', 'link-7');">value</a></tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line">            <tt id="link-24" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-24', 'root', 'link-9');">root</a></tt><tt class="py-op">.</tt><tt class="py-name">appendChild</tt><tt class="py-op">(</tt><tt class="py-name">node</tt><tt class="py-op">)</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">doc</tt> </tt>
</div><a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line"> </tt>
<a name="Action.parse"></a><div id="Action.parse-def"><a name="L72"></a><tt class="py-lineno"> 72</tt> <a class="py-toggle" href="#" id="Action.parse-toggle" onclick="return toggle('Action.parse');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.Action-class.html#parse">parse</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">element</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Action.parse-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Action.parse-expanded"><a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">        <tt class="py-keyword">assert</tt> <tt class="py-name">element</tt><tt class="py-op">.</tt><tt class="py-name">tagName</tt> <tt class="py-op">==</tt> <tt class="py-string">'action'</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-25" class="py-name"><a title="psychsim.action.Action.clear
psychsim.probability.Distribution.clear" class="py-name" href="#" onclick="return doclink('link-25', 'clear', 'link-8');">clear</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">        <tt class="py-name">child</tt> <tt class="py-op">=</tt> <tt class="py-name">element</tt><tt class="py-op">.</tt><tt class="py-name">firstChild</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">        <tt class="py-keyword">while</tt> <tt class="py-name">child</tt><tt class="py-op">:</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt class="py-name">nodeType</tt> <tt class="py-op">==</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt class="py-name">ELEMENT_NODE</tt><tt class="py-op">:</tt> </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line">                <tt class="py-keyword">assert</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt class="py-name">tagName</tt> <tt class="py-op">==</tt> <tt class="py-string">'entry'</tt> </tt>
<a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line">                <tt class="py-name">key</tt> <tt class="py-op">=</tt> <tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">.</tt><tt class="py-name">getAttribute</tt><tt class="py-op">(</tt><tt class="py-string">'key'</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line">                <tt class="py-name">subchild</tt> <tt class="py-op">=</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt class="py-name">firstChild</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line">                <tt class="py-keyword">while</tt> <tt class="py-name">subchild</tt><tt class="py-op">.</tt><tt class="py-name">nodeType</tt> <tt class="py-op">!=</tt> <tt class="py-name">subchild</tt><tt class="py-op">.</tt><tt class="py-name">TEXT_NODE</tt><tt class="py-op">:</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">                    <tt class="py-name">subchild</tt> <tt class="py-op">=</tt> <tt class="py-name">subchild</tt><tt class="py-op">.</tt><tt class="py-name">nextSibling</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">                <tt id="link-26" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-26', 'value', 'link-7');">value</a></tt> <tt class="py-op">=</tt> <tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">subchild</tt><tt class="py-op">.</tt><tt class="py-name">data</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">strip</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">key</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-27" class="py-name"><a title="psychsim.action.Action.special" class="py-name" href="#" onclick="return doclink('link-27', 'special', 'link-0');">special</a></tt><tt class="py-op">:</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line">                    <tt class="py-keyword">if</tt> <tt class="py-string">'.'</tt> <tt class="py-keyword">in</tt> <tt id="link-28" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-28', 'value', 'link-7');">value</a></tt><tt class="py-op">:</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">                        <tt id="link-29" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-29', 'value', 'link-7');">value</a></tt> <tt class="py-op">=</tt> <tt class="py-name">float</tt><tt class="py-op">(</tt><tt id="link-30" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-30', 'value', 'link-7');">value</a></tt><tt class="py-op">)</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line">                    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line">                        <tt id="link-31" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-31', 'value', 'link-7');">value</a></tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt id="link-32" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-32', 'value', 'link-7');">value</a></tt><tt class="py-op">)</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt id="link-33" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-33', 'value', 'link-7');">value</a></tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">            <tt class="py-name">child</tt> <tt class="py-op">=</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt class="py-name">nextSibling</tt> </tt>
</div></div><a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">     </tt>
<a name="ActionSet"></a><div id="ActionSet-def"><a name="L92"></a><tt class="py-lineno"> 92</tt> <a class="py-toggle" href="#" id="ActionSet-toggle" onclick="return toggle('ActionSet');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="psychsim.action.ActionSet-class.html">ActionSet</a><tt class="py-op">(</tt><tt class="py-base-class">frozenset</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ActionSet-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="ActionSet-expanded"><a name="ActionSet.match"></a><div id="ActionSet.match-def"><a name="L93"></a><tt class="py-lineno"> 93</tt> <a class="py-toggle" href="#" id="ActionSet.match-toggle" onclick="return toggle('ActionSet.match');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.ActionSet-class.html#match">match</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">pattern</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ActionSet.match-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ActionSet.match-expanded"><a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line"><tt class="py-docstring">        @param pattern: a table of key-value patterns that the action must match</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line"><tt class="py-docstring">        @type pattern: dict</tt> </tt>
<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line"><tt class="py-docstring">        @return: the first action that matches the given pattern, or C{None} if none</tt> </tt>
<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line"><tt class="py-docstring">        @rtype: L{Action}</tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt id="link-34" class="py-name" targets="Module psychsim.action=psychsim.action-module.html"><a title="psychsim.action" class="py-name" href="#" onclick="return doclink('link-34', 'action', 'link-34');">action</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">:</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">            <tt class="py-keyword">for</tt> <tt class="py-name">key</tt><tt class="py-op">,</tt><tt id="link-35" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-35', 'value', 'link-7');">value</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">pattern</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt id="link-36" class="py-name"><a title="psychsim.action" class="py-name" href="#" onclick="return doclink('link-36', 'action', 'link-34');">action</a></tt><tt class="py-op">.</tt><tt class="py-name">has_key</tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> <tt class="py-keyword">or</tt> <tt id="link-37" class="py-name"><a title="psychsim.action" class="py-name" href="#" onclick="return doclink('link-37', 'action', 'link-34');">action</a></tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt id="link-38" class="py-name"><a title="psychsim.agent.Agent.value" class="py-name" href="#" onclick="return doclink('link-38', 'value', 'link-7');">value</a></tt><tt class="py-op">:</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">                    <tt class="py-comment"># Mismatch</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">                    <tt class="py-keyword">break</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">                <tt class="py-comment"># Match</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">                <tt class="py-keyword">return</tt> <tt id="link-39" class="py-name"><a title="psychsim.action" class="py-name" href="#" onclick="return doclink('link-39', 'action', 'link-34');">action</a></tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">            <tt class="py-comment"># No matching actions</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">None</tt> </tt>
</div><a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line"> </tt>
<a name="ActionSet.__new__"></a><div id="ActionSet.__new__-def"><a name="L112"></a><tt class="py-lineno">112</tt> <a class="py-toggle" href="#" id="ActionSet.__new__-toggle" onclick="return toggle('ActionSet.__new__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.ActionSet-class.html#__new__">__new__</a><tt class="py-op">(</tt><tt class="py-param">cls</tt><tt class="py-op">,</tt><tt class="py-param">elements</tt><tt class="py-op">=</tt><tt class="py-op">[</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ActionSet.__new__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ActionSet.__new__-expanded"><a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">elements</tt><tt class="py-op">,</tt><tt class="py-name">NodeList</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">            <tt class="py-name">iterable</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">            <tt class="py-keyword">for</tt> <tt class="py-name">node</tt> <tt class="py-keyword">in</tt> <tt class="py-name">elements</tt><tt class="py-op">:</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">node</tt><tt class="py-op">.</tt><tt class="py-name">nodeType</tt> <tt class="py-op">==</tt> <tt class="py-name">node</tt><tt class="py-op">.</tt><tt class="py-name">ELEMENT_NODE</tt><tt class="py-op">:</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">                    <tt class="py-keyword">assert</tt> <tt class="py-name">node</tt><tt class="py-op">.</tt><tt class="py-name">tagName</tt> <tt class="py-op">==</tt> <tt class="py-string">'action'</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">                    <tt class="py-name">iterable</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt id="link-40" class="py-name"><a title="psychsim.action.Action" class="py-name" href="#" onclick="return doclink('link-40', 'Action', 'link-12');">Action</a></tt><tt class="py-op">(</tt><tt class="py-name">node</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">elements</tt><tt class="py-op">,</tt><tt class="py-name">dict</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">            <tt class="py-name">iterable</tt> <tt class="py-op">=</tt> <tt class="py-name">reduce</tt><tt class="py-op">(</tt><tt id="link-41" class="py-name" targets="Class psychsim.action.ActionSet=psychsim.action.ActionSet-class.html"><a title="psychsim.action.ActionSet" class="py-name" href="#" onclick="return doclink('link-41', 'ActionSet', 'link-41');">ActionSet</a></tt><tt class="py-op">.</tt><tt class="py-name">union</tt><tt class="py-op">,</tt><tt class="py-name">elements</tt><tt class="py-op">.</tt><tt class="py-name">values</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt id="link-42" class="py-name"><a title="psychsim.action.ActionSet" class="py-name" href="#" onclick="return doclink('link-42', 'ActionSet', 'link-41');">ActionSet</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">            <tt class="py-name">iterable</tt> <tt class="py-op">=</tt> <tt class="py-name">elements</tt> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">frozenset</tt><tt class="py-op">.</tt><tt id="link-43" class="py-name" targets="Static Method psychsim.action.ActionSet.__new__()=psychsim.action.ActionSet-class.html#__new__"><a title="psychsim.action.ActionSet.__new__" class="py-name" href="#" onclick="return doclink('link-43', '__new__', 'link-43');">__new__</a></tt><tt class="py-op">(</tt><tt class="py-name">cls</tt><tt class="py-op">,</tt><tt class="py-name">iterable</tt><tt class="py-op">)</tt> </tt>
</div><a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line"> </tt>
<a name="ActionSet.__getitem__"></a><div id="ActionSet.__getitem__-def"><a name="L125"></a><tt class="py-lineno">125</tt> <a class="py-toggle" href="#" id="ActionSet.__getitem__-toggle" onclick="return toggle('ActionSet.__getitem__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.ActionSet-class.html#__getitem__">__getitem__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ActionSet.__getitem__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ActionSet.__getitem__-expanded"><a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line">        <tt class="py-name">elements</tt> <tt class="py-op">=</tt> <tt class="py-name">list</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line">        <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt class="py-name">elements</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> </tt>
<a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">atom</tt> <tt class="py-keyword">in</tt> <tt class="py-name">elements</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
<a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">atom</tt><tt class="py-op">.</tt><tt class="py-name">has_key</tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> <tt class="py-keyword">and</tt> <tt class="py-name">atom</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">result</tt><tt class="py-op">:</tt> </tt>
<a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line">                <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">,</tt><tt class="py-string">'Conflicting values for key: %s'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> </tt>
<a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">result</tt> </tt>
</div><a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line"> </tt>
<a name="ActionSet.__str__"></a><div id="ActionSet.__str__-def"><a name="L133"></a><tt class="py-lineno">133</tt> <a class="py-toggle" href="#" id="ActionSet.__str__-toggle" onclick="return toggle('ActionSet.__str__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.ActionSet-class.html#__str__">__str__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ActionSet.__str__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ActionSet.__str__-expanded"><a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">','</tt><tt class="py-op">.</tt><tt id="link-44" class="py-name"><a title="psychsim.pwl.VectorDistribution.join" class="py-name" href="#" onclick="return doclink('link-44', 'join', 'link-19');">join</a></tt><tt class="py-op">(</tt><tt class="py-name">map</tt><tt class="py-op">(</tt><tt class="py-name">str</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line"> </tt>
<a name="ActionSet.__hash__"></a><div id="ActionSet.__hash__-def"><a name="L136"></a><tt class="py-lineno">136</tt> <a class="py-toggle" href="#" id="ActionSet.__hash__-toggle" onclick="return toggle('ActionSet.__hash__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.ActionSet-class.html#__hash__">__hash__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ActionSet.__hash__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ActionSet.__hash__-expanded"><a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hash</tt><tt class="py-op">(</tt><tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line"> </tt>
<a name="ActionSet.__xml__"></a><div id="ActionSet.__xml__-def"><a name="L139"></a><tt class="py-lineno">139</tt> <a class="py-toggle" href="#" id="ActionSet.__xml__-toggle" onclick="return toggle('ActionSet.__xml__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action.ActionSet-class.html#__xml__">__xml__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ActionSet.__xml__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ActionSet.__xml__-expanded"><a name="L140"></a><tt class="py-lineno">140</tt>  <tt class="py-line">        <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt class="py-name">Document</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line">        <tt id="link-45" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-45', 'root', 'link-9');">root</a></tt> <tt class="py-op">=</tt> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">createElement</tt><tt class="py-op">(</tt><tt class="py-string">'option'</tt><tt class="py-op">)</tt> </tt>
<a name="L142"></a><tt class="py-lineno">142</tt>  <tt class="py-line">        <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">appendChild</tt><tt class="py-op">(</tt><tt id="link-46" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-46', 'root', 'link-9');">root</a></tt><tt class="py-op">)</tt> </tt>
<a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">atom</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">:</tt> </tt>
<a name="L144"></a><tt class="py-lineno">144</tt>  <tt class="py-line">            <tt id="link-47" class="py-name"><a title="psychsim.action.Action.root" class="py-name" href="#" onclick="return doclink('link-47', 'root', 'link-9');">root</a></tt><tt class="py-op">.</tt><tt class="py-name">appendChild</tt><tt class="py-op">(</tt><tt class="py-name">atom</tt><tt class="py-op">.</tt><tt id="link-48" class="py-name" targets="Method psychsim.action.Action.__xml__()=psychsim.action.Action-class.html#__xml__,Method psychsim.action.ActionSet.__xml__()=psychsim.action.ActionSet-class.html#__xml__,Method psychsim.agent.Agent.__xml__()=psychsim.agent.Agent-class.html#__xml__,Method psychsim.agent.ValueFunction.__xml__()=psychsim.agent.ValueFunction-class.html#__xml__,Method psychsim.probability.Distribution.__xml__()=psychsim.probability.Distribution-class.html#__xml__,Method psychsim.pwl.KeyedMatrix.__xml__()=psychsim.pwl.KeyedMatrix-class.html#__xml__,Method psychsim.pwl.KeyedPlane.__xml__()=psychsim.pwl.KeyedPlane-class.html#__xml__,Method psychsim.pwl.KeyedTree.__xml__()=psychsim.pwl.KeyedTree-class.html#__xml__,Method psychsim.pwl.KeyedVector.__xml__()=psychsim.pwl.KeyedVector-class.html#__xml__,Method psychsim.world.World.__xml__()=psychsim.world.World-class.html#__xml__"><a title="psychsim.action.Action.__xml__
psychsim.action.ActionSet.__xml__
psychsim.agent.Agent.__xml__
psychsim.agent.ValueFunction.__xml__
psychsim.probability.Distribution.__xml__
psychsim.pwl.KeyedMatrix.__xml__
psychsim.pwl.KeyedPlane.__xml__
psychsim.pwl.KeyedTree.__xml__
psychsim.pwl.KeyedVector.__xml__
psychsim.world.World.__xml__" class="py-name" href="#" onclick="return doclink('link-48', '__xml__', 'link-48');">__xml__</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">documentElement</tt><tt class="py-op">)</tt> </tt>
<a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">doc</tt> </tt>
</div></div><a name="L146"></a><tt class="py-lineno">146</tt>  <tt class="py-line"> </tt>
<a name="filterActions"></a><div id="filterActions-def"><a name="L147"></a><tt class="py-lineno">147</tt> <a class="py-toggle" href="#" id="filterActions-toggle" onclick="return toggle('filterActions');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="psychsim.action-module.html#filterActions">filterActions</a><tt class="py-op">(</tt><tt class="py-param">pattern</tt><tt class="py-op">,</tt><tt class="py-param">actions</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="filterActions-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="filterActions-expanded"><a name="L148"></a><tt class="py-lineno">148</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L149"></a><tt class="py-lineno">149</tt>  <tt class="py-line"><tt class="py-docstring">    @type pattern: dict</tt> </tt>
<a name="L150"></a><tt class="py-lineno">150</tt>  <tt class="py-line"><tt class="py-docstring">    @return: the subset of given actions that match the given pattern</tt> </tt>
<a name="L151"></a><tt class="py-lineno">151</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L152"></a><tt class="py-lineno">152</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-49" class="py-name"><a title="psychsim.pwl.KeyedVector.filter" class="py-name" href="#" onclick="return doclink('link-49', 'filter', 'link-4');">filter</a></tt><tt class="py-op">(</tt><tt class="py-keyword">lambda</tt> <tt class="py-name">a</tt><tt class="py-op">:</tt> <tt class="py-name">a</tt><tt class="py-op">.</tt><tt id="link-50" class="py-name" targets="Method psychsim.action.ActionSet.match()=psychsim.action.ActionSet-class.html#match"><a title="psychsim.action.ActionSet.match" class="py-name" href="#" onclick="return doclink('link-50', 'match', 'link-50');">match</a></tt><tt class="py-op">(</tt><tt class="py-name">pattern</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-name">actions</tt><tt class="py-op">)</tt> </tt>
</div><a name="L153"></a><tt class="py-lineno">153</tt>  <tt class="py-line"> </tt>
<a name="L154"></a><tt class="py-lineno">154</tt>  <tt class="py-line"><tt class="py-keyword">if</tt> <tt class="py-name">__name__</tt> <tt class="py-op">==</tt> <tt class="py-string">'__main__'</tt><tt class="py-op">:</tt> </tt>
<a name="L155"></a><tt class="py-lineno">155</tt>  <tt class="py-line">    <tt class="py-name">act1</tt> <tt class="py-op">=</tt> <tt id="link-51" class="py-name"><a title="psychsim.action.Action" class="py-name" href="#" onclick="return doclink('link-51', 'Action', 'link-12');">Action</a></tt><tt class="py-op">(</tt><tt class="py-op">{</tt><tt class="py-string">'subject'</tt><tt class="py-op">:</tt> <tt class="py-string">'I'</tt><tt class="py-op">,</tt><tt class="py-string">'verb'</tt><tt class="py-op">:</tt> <tt class="py-string">'help'</tt><tt class="py-op">,</tt><tt class="py-string">'object'</tt><tt class="py-op">:</tt> <tt class="py-string">'you'</tt><tt class="py-op">}</tt><tt class="py-op">)</tt>     </tt>
<a name="L156"></a><tt class="py-lineno">156</tt>  <tt class="py-line">    <tt class="py-name">act2</tt> <tt class="py-op">=</tt> <tt id="link-52" class="py-name"><a title="psychsim.action.Action" class="py-name" href="#" onclick="return doclink('link-52', 'Action', 'link-12');">Action</a></tt><tt class="py-op">(</tt><tt class="py-op">{</tt><tt class="py-string">'subject'</tt><tt class="py-op">:</tt> <tt class="py-string">'you'</tt><tt class="py-op">,</tt><tt class="py-string">'verb'</tt><tt class="py-op">:</tt> <tt class="py-string">'help'</tt><tt class="py-op">,</tt><tt class="py-string">'object'</tt><tt class="py-op">:</tt> <tt class="py-string">'I'</tt><tt class="py-op">}</tt><tt class="py-op">)</tt> </tt>
<a name="L157"></a><tt class="py-lineno">157</tt>  <tt class="py-line">    <tt class="py-name">old</tt> <tt class="py-op">=</tt> <tt id="link-53" class="py-name"><a title="psychsim.action.ActionSet" class="py-name" href="#" onclick="return doclink('link-53', 'ActionSet', 'link-41');">ActionSet</a></tt><tt class="py-op">(</tt><tt class="py-op">[</tt><tt class="py-name">act1</tt><tt class="py-op">,</tt><tt class="py-name">act2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L158"></a><tt class="py-lineno">158</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-name">old</tt> </tt>
<a name="L159"></a><tt class="py-lineno">159</tt>  <tt class="py-line">    <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt class="py-name">parseString</tt><tt class="py-op">(</tt><tt class="py-name">old</tt><tt class="py-op">.</tt><tt id="link-54" class="py-name"><a title="psychsim.action.Action.__xml__
psychsim.action.ActionSet.__xml__
psychsim.agent.Agent.__xml__
psychsim.agent.ValueFunction.__xml__
psychsim.probability.Distribution.__xml__
psychsim.pwl.KeyedMatrix.__xml__
psychsim.pwl.KeyedPlane.__xml__
psychsim.pwl.KeyedTree.__xml__
psychsim.pwl.KeyedVector.__xml__
psychsim.world.World.__xml__" class="py-name" href="#" onclick="return doclink('link-54', '__xml__', 'link-48');">__xml__</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">toprettyxml</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L160"></a><tt class="py-lineno">160</tt>  <tt class="py-line">    <tt class="py-name">new</tt> <tt class="py-op">=</tt> <tt id="link-55" class="py-name"><a title="psychsim.action.ActionSet" class="py-name" href="#" onclick="return doclink('link-55', 'ActionSet', 'link-41');">ActionSet</a></tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">documentElement</tt><tt class="py-op">.</tt><tt class="py-name">childNodes</tt><tt class="py-op">)</tt> </tt>
<a name="L161"></a><tt class="py-lineno">161</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-name">new</tt> </tt>
<a name="L162"></a><tt class="py-lineno">162</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-name">old</tt> <tt class="py-op">==</tt> <tt class="py-name">new</tt> </tt>
<a name="L163"></a><tt class="py-lineno">163</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="psychsim.world.World-class.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://pynadath.net:81/projects/psychsim">PsychSim</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Wed Oct 24 21:38:11 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
